<template>


    <a-modal
      :title="title"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"

    >
      <a-form >
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="上传频率" :labelCol="labelCol" :wrapperCol="wrapperCol">
               <a-input placeholder='请输入上传频率' v-model="model.deviceFrequencyTime"  ></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item label="上传频率":labelCol="labelCol" :wrapperCol="wrapperCol">
            <j-dict-select-tag type="radio" v-model="model.deviceFrequencyTimeUnit"  dictCode="time_unit"></j-dict-select-tag>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form>
    </a-modal>


</template>
<script>

import { putAction } from '@api/manage'


export default {
  name: 'SetDeviceConfigModal',

  data() {

    return {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      model:{
        deviceNo:undefined,
        deviceFrequencyTimeUnit :undefined,
        deviceFrequencyTime:undefined
      },

      confirmLoading: false,
      title:"修改上传频率",
      visible: false,
    };
  },
computed:{

},
  methods: {
    showModal(r) {

      this.model.deviceNo =r.deviceNo;
      this.model.deviceFrequencyTime =r.reportedTime;
      this.model.deviceFrequencyTimeUnit=r.reportedTimeUnit;

      this.visible = true;
    },
    handleOk(e) {
   var that  = this;
      this.confirmLoading = true;
      console.log(this.model)
      putAction("alldeviceapi/sys/api/device/upload/frequency",this.model).then(
        result=>{
          console.log(result)
          if (result.code==200){
            that.confirmLoading = false;
            that.visible = false;
            that.$message.success(result.message);
            
          }else {
            that.confirmLoading = false;
            that.visible = false;
            that.$message.warn(result.message);


          }
        }
      ).finally()


    },
    handleCancel(e) {

      this.visible = false;
    },



  },
};
</script>
